﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace 字典01
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            ht.Add(1, "张三");
            ht.Add("ss", false);
            ht.Add(1.2, 1.1f);

            Student stu1 = new Student();
            ht.Add("第一个学生", stu1);

            ICollection ic = ht.Keys;
            foreach (var item in ic)
            {
                Console.WriteLine(item);
            }

            foreach (var item in ht.Values)
            {
                Console.WriteLine(item);
            }

            //string str = (string)ht[1];
            ht[1] = "lisi";
            Console.WriteLine(ht[1]);
            bool b = (bool)ht["ss"];
            Console.WriteLine(b);

            Console.WriteLine("----------");
            Console.WriteLine();
            Console.WriteLine();

            IDictionaryEnumerator ie = ht.GetEnumerator();
            while (ie.MoveNext())   //可以判断是否有下一个元素
            {
                Console.WriteLine("---");
                Console.WriteLine("Key:" + ie.Key + " Value:" + ie.Value);
            }
        }
    }

    class Student
    {

    }
}
